<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>MutationObserver</title>
</head>
<body>

  <script>
    const target = document.getElementById('kolor-kolor');
    const observer = new MutationObserver(function(mutationList, observe) {
      console.log(mutationList, '-------');
      if (mutationList[0].type === 'attributes') {
        let ans = target.style.backgroundColor; // 正确答案
        document.querySelectorAll('kolor-options a').forEach(node => {
          if (node.style.backgroundColor === ans) {
            node.click();
          }
        })
      }
    });

    observer.observe(target, {
      attributes: true,
      // childList: true,
      // subtree: true
    });
  </script>
</body>
</html>